#!/bin/bash
cd ..
WORK_DIR=$(pwd)
# 设置构建目录 build
BUILD_DIR=${WORK_DIR}/build
# 判断 build 文件夹是否存在
if [ ! -d ${BUILD_DIR} ]; then
    mkdir -p ${BUILD_DIR}
fi

# ndk 主目录
ANDROID_NDK=$BUILD_DIR/android-ndk-r21e
TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
export API=21

function build_android
{
./configure \
    --prefix=$PREFIX \
	 --disable-cli \
    --enable-static \
    --enable-shared \
    --enable-pic \
    --host=$my_host \
	  --cross-prefix=$CROSS_PREFIX \
    --sysroot=$TOOLCHAIN/sysroot \

make clean
make -j8
make install
}

#armeabi-v7a
PREFIX=$BUILD_DIR/android/armv7-a/21
my_host=armv7a-linux-android
export TARGET=armv7a-linux-androideabi
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
CROSS_PREFIX=$TOOLCHAIN/bin/arm-linux-androideabi-
cd ${BUILD_DIR}/x264
build_android